Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/event bus #1063

Merged

Conversation

farskipper
Copy link
Contributor

This adds an event bus and utilizes it to simplify webhooks. Events are emitted and the Admin Server subscribes to some of them to be forwarded as webhooks. Here is a diagram outlining the refactor: https://hackmd.io/IoDqYR_cS3yRAe7DI8JAiA

Events are namespaced. acapy::* events are anything originating from ACA-Py this way plugins can use their own events without collision.

Some notable changes:

Responder.send_webhook

Is deprecated, it emits a warning and uses the acapy::webhook::{TOPIC} event to retain backwards compatibility.

BaseRecord webhooks

Instead of sending a webhook, it now emits an event. As such, WEBHOOK_TOPIC -> RECORD_TOPIC and send_webhook -> emit_event

The record event topic follows this pattern: acapy::record::{RECORD_TOPIC}::{STATE}

Removed Admin Server webhook_targets

It appears that the admin server webhook_targets are no longer used. See: https://github.com/hyperledger/aries-cloudagent-python/blob/main/aries_cloudagent/admin/server.py#L754-L755 Instead we just rely on profile.settings.get("admin.webhook_urls")

As such, the following are removed:

  • BaseAdminServer.add_webhook_target
  • BaseAdminServer.remove_webhook_target
  • BaseAdminServer.send_webhook

dbluhm and others added 17 commits February 3, 2021 20:54
Signed-off-by: Daniel Bluhm <[email protected]>
In the future, this should be inverted.

Signed-off-by: Daniel Bluhm <[email protected]>
Signed-off-by: Matthew Wright <[email protected]>
…ase_record

Base record replace webhooks with events
AdminServer is now the only one to send_webhook
@swcurran
Copy link
Contributor

swcurran commented Apr 5, 2021

Something for @shaangill025 @andrewwhitehead and @TimoGlastra to look at it. And anyone else working on ACA-Py, of course!

Thanks!

@airoasis
Copy link

airoasis commented Apr 6, 2021

Is it resolving the issue #950 as well?

@ianco
Copy link
Contributor

ianco commented Apr 6, 2021

Are there any changes to aca-py startup parameters, or any changes to how the controller interacts with aca-py?

@ianco
Copy link
Contributor

ianco commented Apr 6, 2021

I ran a quick test of the Alice/Faber demo (startup the 2 agents, establish connection, issue credential from faber -> alice and then ask for proof request), it looks like Alice doesn't receive the proof request on the last step.

@dbluhm
Copy link
Contributor

dbluhm commented Apr 6, 2021

The goal is for the webhook listeners and controller to operate exactly as before. @farskipper we'll have to check out the issues with the demo.

@dbluhm
Copy link
Contributor

dbluhm commented Apr 6, 2021

Is it resolving the issue #950 as well?

@airoasis This does not impact #950. This change just adds a layer between ACA-Py and the Webhook emitter that enables plugins to process events without needing to run a whole webserver to listen for webhooks.

@farskipper
Copy link
Contributor Author

@ianco I updated the branch and made a small fix. Now I'm able to get through the Alice/Faber demo.

@andrewwhitehead
Copy link
Contributor

This looks great to me so far, and running the performance demo it seems to be performing 20-30% faster running native on my Mac (it takes longer to finish starting the credential exchanges, but finishes sooner). @ianco Are you able to test the stability on openshift?

@andrewwhitehead andrewwhitehead requested a review from sklump April 13, 2021 20:30
@ianco
Copy link
Contributor

ianco commented Apr 22, 2021

This looks great to me so far, and running the performance demo it seems to be performing 20-30% faster running native on my Mac (it takes longer to finish starting the credential exchanges, but finishes sooner). @ianco Are you able to test the stability on openshift?

We need to build a docker image in order to deploy/test on openshift, prob worth doing once we merge this and any other big PR's (for example I'd like to get the shared-components onto openshift as well).

@ianco
Copy link
Contributor

ianco commented Apr 22, 2021

Overall looks really good. Is the EventBus pluggable? Seems like a good fit for the persistent queue.

@dbluhm
Copy link
Contributor

dbluhm commented Apr 23, 2021

Overall looks really good. Is the EventBus pluggable? Seems like a good fit for the persistent queue.

Interesting question... The current implementation aims to be simple so that components within ACA-Py and attached plugins can receive the same events originally sent only by the admin server via web hooks. Using a plugin, you can subscribe to events and then push those to an external queue or notification system. I'm not sure I see what you mean about using it with the persistent queue yet.

@codecov-commenter
Copy link

codecov-commenter commented Apr 23, 2021

Codecov Report

Merging #1063 (708f9d3) into main (8a60d1a) will decrease coverage by 0.10%.
The diff coverage is 85.82%.

@@            Coverage Diff             @@
##             main    #1063      +/-   ##
==========================================
- Coverage   99.29%   99.19%   -0.11%     
==========================================
  Files         382      383       +1     
  Lines       22099    22133      +34     
==========================================
+ Hits        21943    21954      +11     
- Misses        156      179      +23     

LOGGER.debug("Unsubscribed: topic %s, processor %s", pattern, processor)


class MockEventBus(EventBus):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a test class for test purposes that only is used on unit tests.
This shouldn't be declared here, isn't it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This follows a pattern used elsewhere in ACA-Py so I don't see a problem with defining it here. This makes it easier to reuse in tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can webhooks be generalized? Or a different solution?
8 participants